<template>
  <div class="dialog">
    <el-dialog width="70%" title="游记详情" :visible="true" :close-on-click-modal="false" :before-close="close">
      <el-form ref="form" :model="form" label-width="110px" disabled>
        <el-form-item label="游记图片：">
          <el-col :span="20">
            <UploadFile :file-list="form.contentImgStr" />
          </el-col>
        </el-form-item>
        <el-form-item label="发布人：">
          <el-col :span="12">
            <el-input v-model="form.nickname" />
          </el-col>
        </el-form-item>
        <el-form-item label="游记标题：">
          <el-col :span="12">
            <el-input v-model="form.title" />
          </el-col>
        </el-form-item>
        <el-form-item label="游记内容：">
          <el-col :span="20">
            <el-input v-model="form.content" type="textarea" rows="5" />
          </el-col>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import UploadFile from '@/components/UploadFile/index.vue'
import { getTravelDetail } from '@/api/content'
export default {
  name: 'TravelDetail',
  components: { UploadFile },
  props: {
    id: {
      type: [Number, String],
      default: ''
    }
  },

  data() {
    return {
      loading: false,
      form: {
        contentImgStr: '',
        nickname: '',
        title: '',
        content: ''
      }
    }
  },

  created() {
    this.getDetail()
  },

  methods: {

    // 取消
    close() {
      this.$emit('close')
    },

    // 详情
    getDetail() {
      const data = {
        travelId: this.id
      }
      getTravelDetail(data).then(res => {
        const { contentImgStr, nickname, title, content } = res || {}
        this.form = {
          contentImgStr,
          nickname,
          title,
          content
        }
      }).catch(() => {})
    }

  }

}
</script>

<style lang="scss" scoped></style>
